namespace MVC4_Test.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitialCreate : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Questions",
                c => new
                    {
                        QuestionId = c.Int(nullable: false, identity: true),
                        Text = c.String(),
                        Title = c.String(),
                        View = c.Int(nullable: false),
                        Date = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.QuestionId);
            
            CreateTable(
                "dbo.Tags",
                c => new
                    {
                        TagId = c.Int(nullable: false, identity: true),
                        Text = c.String(),
                        Question_QuestionId = c.Int(),
                    })
                .PrimaryKey(t => t.TagId)
                .ForeignKey("dbo.Questions", t => t.Question_QuestionId)
                .Index(t => t.Question_QuestionId);
            
            CreateTable(
                "dbo.TagQuestions",
                c => new
                    {
                        TagQuestionId = c.Int(nullable: false, identity: true),
                        Tag = c.Int(nullable: false),
                        QuestionId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.TagQuestionId);
            
            CreateTable(
                "dbo.Answers",
                c => new
                    {
                        AnswerId = c.Int(nullable: false, identity: true),
                        UserId = c.Int(nullable: false),
                        Text = c.String(),
                        Date = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.AnswerId);
            
            CreateTable(
                "dbo.AnswerQuestions",
                c => new
                    {
                        AnswerQuestionId = c.Int(nullable: false, identity: true),
                        AnswerId = c.Int(nullable: false),
                        QuestionId = c.Int(nullable: false),
                        IsCorrect = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.AnswerQuestionId);
            
            CreateTable(
                "dbo.AnswerVotes",
                c => new
                    {
                        AnswerVoteId = c.Int(nullable: false, identity: true),
                        AnswerId = c.Int(nullable: false),
                        VoteId = c.Int(nullable: false),
                        UserId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.AnswerVoteId);
            
            CreateTable(
                "dbo.Favorites",
                c => new
                    {
                        FavoriteId = c.Int(nullable: false, identity: true),
                        UserId = c.Int(nullable: false),
                        QuestionId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.FavoriteId);
            
            CreateTable(
                "dbo.QuestionVotes",
                c => new
                    {
                        QuestionVoteId = c.Int(nullable: false, identity: true),
                        QuestionId = c.Int(nullable: false),
                        VoteId = c.Int(nullable: false),
                        UserId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.QuestionVoteId);
            
            CreateTable(
                "dbo.Votes",
                c => new
                    {
                        VoteId = c.Int(nullable: false, identity: true),
                        Counter = c.Int(nullable: false),
                        Date = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.VoteId);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.Tags", new[] { "Question_QuestionId" });
            DropForeignKey("dbo.Tags", "Question_QuestionId", "dbo.Questions");
            DropTable("dbo.Votes");
            DropTable("dbo.QuestionVotes");
            DropTable("dbo.Favorites");
            DropTable("dbo.AnswerVotes");
            DropTable("dbo.AnswerQuestions");
            DropTable("dbo.Answers");
            DropTable("dbo.TagQuestions");
            DropTable("dbo.Tags");
            DropTable("dbo.Questions");
        }
    }
}
